using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ent.Web.Helper;
using Ent.Voice;
using Ent.Voice.Nomination;
public partial class ShowUser : System.Web.UI.Page
{
    private int _pageIndex = 1;
    public int PageIndex
    {
        get { return _pageIndex; }
        set { _pageIndex = value; }
    }
    public ShowUser()
    {
        this.PreRender += new EventHandler(ShowUser_PreRender);
    }

    void ShowUser_PreRender(object sender, EventArgs e)
    {
        SetDetails();
    }
    private void SetDetails()
    {
        try
        {
            string id = Request.QueryString["id"];
            int pi = MathFunction.ConvertToInteger(Request.QueryString["pi"]);
            int o = MathFunction.ConvertToInteger(Request.QueryString["o"]);
            if (o == 0)
                o = Entry.GetOrderBy(OrderBy.None);
            User u = Ent.Voice.User.GetUser(id);
            if (u != null)
            {
                this.Page.Title = u.FName + " " + u.LName + " - " + ResourceHelper.Get("SITE_Title");
                lblDescription.Text = Ent.Web.Helper.StringHelper.RestrictMaxChar(u.AboutMe, 150);
                if (u.DOB != DateTime.MinValue)
                {
                    lblDOB.Text = ResourceHelper.Get("LBL_DOB");
                    lblDOBVal.Text = u.DOB.ToShortDateString();
                }
                else
                    trDOB.Visible = false;
                if (u.Hobbies != "")
                {
                    lblHob.Text = ResourceHelper.Get("LBL_Hob");
                    lblHobVal.Text = Ent.Web.Helper.StringHelper.RestrictMaxChar(u.Hobbies, 30);
                }
                else
                    trHob.Visible = false;
                if (u.Location != "")
                {
                    lblLoc.Text = ResourceHelper.Get("LBL_Loc");
                    lblLocVal.Text = Ent.Web.Helper.StringHelper.RestrictMaxChar(u.Location, 30);
                }
                else
                    trLoc.Visible = false;
                lblPart.Text = ResourceHelper.Get("LBL_Part");
                lblPartVal.Text = u.cntParticipate.ToString();
                lblUserName.Font.Bold = true;
                lblUserName.CssClass = "text14";
                lblUserName.Text = Ent.Web.Helper.StringHelper.RestrictMaxChar(u.FName + " " + u.LName, 30);
                lblViews.Text = ResourceHelper.Get("LBL_Views");
                lblViewsVal.Text = u.Views.ToString();
                imgUser.ImageUrl = Common.GetUserImage(u.PhotoId);
                imgUser.Height = Unit.Pixel(100);
                if (u.CntBronze <= 0 && u.CntGold <= 0 && u.CntSilver <= 0)
                    trMedal.Visible = false;
                else
                {
                    lblMedal.Text = ResourceHelper.Get("LBL_Medal");
                    if (u.CntGold != 0)
                        lblMedalVal.Text += "<img src=\"Images/dj/trophy1.gif\" style='height:25px' />&nbsp;:&nbsp;" + u.CntGold + "&nbsp;&nbsp;&nbsp;&nbsp;";
                    if (u.CntSilver != 0)
                        lblMedalVal.Text += "<img src=\"Images/dj/trophy2.gif\" style='height:25px' />&nbsp;:&nbsp;" + u.CntSilver + "&nbsp;&nbsp;&nbsp;&nbsp;";
                    if (u.CntBronze != 0)
                        lblMedalVal.Text += "<img src=\"Images/dj/mon.gif\" style='height:25px' />&nbsp;:&nbsp;" + u.CntBronze;
                }

                cEntries.Id = u.UserID;
                cEntries.HeaderText = ResourceHelper.Get("LBL_OtherEntries");
                cEntries.PageIndex = pi <= 0 ? 1 : pi;
                cEntries.OrderBy = Entry.GetOrderBy(o);

                if (Session["USERID"] != null && id != Session["USERID"].ToString())
                    lblSendMail.Text = Common.GetImageTextLink("SendMessage.aspx?id=" + id, "Images/dj/mail.gif", ResourceHelper.Get("MSG_SendMail"), 20);

            }
            else
                Common.WarnPage("InvalidUser");
        }
        catch (Exception exc)
        {
            if (exc.Message == "InvalidUser")
                Common.WarnPage("InvalidUser");
            Common.ErrorPage(exc);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMedalVal.Text = "";
    }
}
